<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" href="../../css/global/mui.css">
<link rel="stylesheet" type="text/css" href="../../css/global/public.css"/>
<link rel="stylesheet" type="text/css" href="../../css/doctor-details.css"/>
<link rel="stylesheet" type="text/css" href="../../css/doctor-abstract.css"/>
<link rel="stylesheet" type="text/css" href="../../css/patient-evaluation.css" />
<script type="text/javascript" src="../../js/common/common.js"></script>
<title>医生主页</title>
</head>
<body>
	<div class="doctor2-top">
		<div class="doctor2-box">
			<div class="text">
				<div class="picture"><img src="../../images/doc-man.png"/></div>
				<font id="uName" class="font3">王小二</font>
				<p><font id="xlys" class="font3">主任医师</font><span id="deptName"class="font3">普通精神科</span></p>
				<p id="hospitalName" class="font3">宜昌馨语医院</p>
				<div class="concern font3">
					<span class="add-doctor">＋收藏</span>
					<span class="remove-doctor" style="display:none;">取消收藏</span>
				</div>
			</div>
			<div class="doctor2-all font3">
				<ul>
					<li>
						服务患者数：<span id="serviceTimes" class="color_orange">0</span>
					</li>
					<li>
						关注人数：<span id="pCount" class="color_orange">0</span>
					</li>
				</ul>
			</div>
		</div>
	</div>
	<div class="doctor2-list">
		<ul>
			<li class="doctor_icon1 font3" t="1">
				<p>
					<a>图文咨询</a>
					<span class="font2"><font class="textshowPirce">0</font>元/次</span>
				</p>
			</li>
			<li class="doctor_icon2 font3" t="2">
				<p>
					<a>电话咨询</a>
					<span class="font2"><font class="phoneshowPirce">0</font>元/次</span>
				</p>
			</li>
		</ul>
	</div>
	<div class="doctor-homeComment">
		<div class="title">
			<span class="font3">医生简介</span>
			<!--<a href="javascript:;" class="font2 abstract">更多  ＞</a>-->
		</div>
		<div class="doctor-abstract">
			<img class="medal" src="../../images/medal.png" alt="" />
			<img class="watermark" src="../../images/watermark.png" alt="" />
			<div id="doctorDes" class="doctorDes font3">
				
			</div>
		</div>
		<div class="skilled">
			<span class="font3">擅长:</span><p id="skilled" class="font3"></p>	
		</div>
	</div>
	<div class="doctor-homeComment">
		<div class="title">
			患者评价
			<span class="more-comment">更多</span>
		</div>
		<ul class="patient-commentlist">
			<!--<li class="patient-comment">
				<a href="#">
					<div class="patient-name">患者名字</div><div class="comment-xingxing comment-image4"></div>
					<p class="font3">谢谢医生,现在好多了.开的药效果真好!!!</p>
				</a>
			</li>-->
		</ul>
	</div>
	
	<input type="hidden"  id="doctorid" value="" />
	<input type="hidden"  id="payAmount" value="" />
	<input type="hidden"  id="textOrderDetail" value="" />
	<input type="hidden"  id="phoneOrderDetail" value="" />
	<input type="hidden"  id="phonePayAmount" value="" />
	<input type="hidden"  id="orderType" value="1" />
	<input type="hidden"  id="serviceDate" value="" />
	<input type="hidden"  id="serviceTime" value="" />
	<input type="hidden" name="startTime" id="startTime" value="" />
	<input type="hidden" name="endTime" id="endTime" value="" />
	<input type="hidden"  id="phoneisopen" value="1" />
	<input type="hidden"  id="imisopen" value="1" />
	
	<div class="doctor-homeBot">
		立即咨询
	</div>
	<div class="consultation-pop" style="display: none;">
		<div class="main">
			<div class="name">
				<span></span>
				<label class="uName font4">找医生 </label><font class="xlys font1">国家二级心理咨询师</font>
				<p>已选择 
					 <label id="TypeLabel">图文咨询</label> 
					 <i id="dateLabel"></i>
			    </p>
			</div>
			<div class="box">
				<div class="title service-type">请选择服务类型</div>
				<ul class="type">
					<li class="images-text active" t="1">
						图文咨询
						<p><font class="textshowPirce">0</font>元/次</p>
					</li>
					<li class="tel-text" t="2">
						电话咨询
						<p><font class="phoneshowPirce">0</font>元/次</p>
					</li>
				</ul>
				<div class="title telephone-date showPhoneDateText" style="display: none;">请选电话咨询日期</div>
				<div class="date showPhoneDateText" style="display: none;">
					<ul class="font2">
						 
					</ul>
				</div>
				<!--日期渲染 -->
				<!--<div class="time showPhoneDateText" style="display:none;">
				</div>-->
				
				
		</div>
		<div class="prompt brompts">医生看到问题留言会即刻回复您,请耐心等待.若24小时内未回复,会将提问金额退还至您的账户.</div>
		<div class="prompt brompt showTip" style="display:none;">
			咨询说明
			</br>1:疑难杂症电话沟通更清楚;
			</br>2:专家医生本人接听解答;
			</br>3:准时接通,无电话费,不接通全额退款.
		</div>
		<button id="confrimBtn">立即咨询</button>
	</div>
	<div class="alert-pop"></div>
</body>
<script type="text/javascript" src="../../js/common/common.js"></script>
<script type="text/javascript" src="../../js/lib/mui.min.js" ></script>
<script type="text/javascript" src="../../js/module/utilModule.js" ></script> 
<script type="text/javascript" src="../../js/common/config.js"></script>
<script type="text/javascript" src="../../js/lib/zepto.min.js" ></script>
<script type="text/javascript" src="../../js/lib/template.js" ></script>
<script type="text/javascript" src="../../js/module/doctorModule.js" ></script>
<script type="text/javascript" src="../../js/doctor/commonService.js"></script>
<script type="text/javascript" src="../../js/doctor/detailDoctor.js" ></script>
<script type="text/javascript" src="../../js/module/orderPayModule.js" ></script>
<script type="text/javascript" src="../../js/common/moment.js"></script>
</html>
<script type="text/javascript">
$(function(){ 	
	$(".consultation-pop .box .type li").click(function(){
		var type=$(this).attr("t");
		$("#orderType").val(type);
		if(type==2){
			$("#TypeLabel").text("电话咨询");
		    $(".showTip").show();
		    $(".showPhoneDateText").show();
		    loadDataList();
		    $(".brompts").hide();
		}else{
			$("#TypeLabel").text("图文咨询");
			$("#dateLabel").text("");
			$(".showTip").hide();
			$(".showPhoneDateText").hide();
		    $(".brompts").show();
		}
		$(this).addClass("active").siblings().removeClass("active");
	});
	
	$(".doctor-homeBot").click(function(){
		if($("#imisopen").val()==0&&$("#phoneisopen").val()==0){
			 mui.alert("该医生暂未开通服务!","提示");
			 return false;
		}
		$(".consultation-pop").fadeIn();
		if($("#imisopen").val()==0){
			$(".tel-text").addClass("active").siblings().removeClass("active");
			$("#TypeLabel").text("电话咨询");
		    $(".showTip").fadeIn("slow");
		    $(".showPhoneDateText").show();
		    $(".brompts").hide();
		    loadDataList();
		}
		$("body").addClass("stopFixed");
	});
    $(".consultation-pop .name span").click(function(){
        $(".consultation-pop").fadeOut();
		$("body").removeClass("stopFixed");
    });

  //选择服务类型触发
    $(".doctor2-list li").click(function(){
   	 $(".consultation-pop").fadeIn();
	 $("body").addClass("stopFixed");
      var type=$(this).attr("t");
      if(type==2){
      	 	var phoneisopen=$("#phoneisopen").val();
      	 	if(phoneisopen==0){
      	 	    $(".consultation-pop").fadeOut();
      	 	    mui.alert("该医生暂未开启电话咨询服务!","提示");
      	 	    return false;
      	 	}
      		$(".tel-text").addClass("active").siblings().removeClass("active");
			$("#TypeLabel").text("电话咨询");
		    $(".showTip").fadeIn("slow");
		    $(".showPhoneDateText").fadeIn("slow");
		    $(".brompts").hide();
		    loadDataList();
		}else{
			var imisopen=$("#imisopen").val();
	      	if(imisopen==0){
	  	 	    $(".consultation-pop").fadeOut();
	  	 	    mui.alert("该医生暂未开启图文咨询服务!","提示");
	  	 	    return false;
  	 		}
			$(".images-text").addClass("active").siblings().removeClass("active");
			$("#TypeLabel").text("图文咨询");
			$("#dateLabel").text("");
			$(".showTip").fadeOut("slow");
			$(".showPhoneDateText").fadeOut("slow");
			$(".brompts").show();
		}
      $("#orderType").val(type);
    })
   
   //快速提问进医生主页
   var isdoctorinfo = utilModule.getQueryString("isdoctorinfo")?utilModule.getQueryString("isdoctorinfo"):0;
	if(isdoctorinfo ==1){
		$("body").css("padding-bottom","0");
		$(".doctor-homeBot").hide();
		$(".doctor2-list li").unbind("click");
	}
   //患者评价
   var doctorId = utilModule.getQueryString("doctorid");
   var params = {
		"doctorId": doctorId
	};
   orderPayModule.patientReview(params,function(callBack) {
   		console.log(callBack);
		if(callBack != null) {
			var $hzHtml="";
			var length = callBack.length;
			
			if(null!=length && length>3){
				length=3;
			}else{
			   $(".doctor-homeComment .more-comment").hide();
			}
			for(var i=0;i<length;i++){
				$hzHtml+='<li class="patient-comment">'+
					'<a href="###">'+
						'<span class="patient-name font2">'+decodeURI(callBack[i].nickname)+'</span><span class="evaluation-createtime font2">'+callBack[i].createtime+'</span><span class="comment-xingxing comment-image'+callBack[i].score+'"></span>'+
						'<p class="font3">'+callBack[i].content+'</p>'+
					'</a></li>';
			}
			$(".patient-commentlist").append($hzHtml);
		}
	});
});	

//请求服务器获取服务时间列表
var serviceDateList=null;
function loadDataList(){
	//日期渲染
	//var data = [{data:'2017-09-25',time:'08:30~12:30'},{data:'2017-09-26',time:'08:30~12:30'},{data:'2017-09-27',time:'08:30~12:30'},{data:'2017-09-28',time:'08:30~12:30'},{data:'2017-09-29',time:'08:30~12:30'}];
	console.log(JSON.stringify(serviceDateList));
	if(serviceDateList==null){
	   var doctorid=$("#doctorid").val()==null?8:$("#doctorid").val();
	   var params={id:doctorid};
	    doctorModule.queryServiceDateList(params,function(callBack) {
		if(callBack != null) {
			serviceDateList=callBack;  
		}
	  });
 	}
 	if(showDateList!=null){
		showDateList(serviceDateList);
	}
}
function gettimeList(s,e,n){
	var totalTime = 24*3600*1000;
	var spanTime = totalTime / 48;
//	var startTime = new Date();
//	startTime.setHours(0, 0, 0, 0);
//	var currentTime = startTime.getTime();
	var currentTime = n;
	var arr ="";
	for(var i = 0; i < 48; i++) {
	   currentTime += spanTime;
	   if(s<= currentTime &&currentTime<=e){
//		   console.log(format(currentTime).substring(11,16));
			if(currentTime>Date.parse(new Date())){
				arr+=format(currentTime).substring(11,16)+",";
			}
		}
	}
	return arr.split(",");
}

function format(shijianchuo){
	//shijianchuo是整数，否则要parseInt转换
	var time = new Date(shijianchuo);
	var y = time.getFullYear();
	var m = time.getMonth()+1;
	var d = time.getDate();
	var h = time.getHours();
	var mm = time.getMinutes();
	var s = time.getSeconds();
	return y+'-'+add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(mm)+':'+add0(s);
}
function add0(m){return m<10?'0'+m:m }
//渲染日期数据
function showDateList(data){
	console.log(data)
//	var html = "";
//	var html2 = "";
//	var html3 ="";
//	if(data==null) {
//	   mui.toast("当前医生没有设置对应的服务 时间!");
//	   return false;
//	}
//  for(var i=0;i<data.length;i++){
//	//时间转为年月日
//		var html = "";
//		var dataz=data[i].date;
//		console.log(data[0].date);
//		var dataz_arr=dataz.split("-");
//		var data_w = dataz_arr[0]+"/"+dataz_arr[1]+"/"+dataz_arr[2];
//		
//		var dataz_new=dataz_arr[0]+"年"+dataz_arr[1]+"月"+dataz_arr[2]+"日";
//		html2+="<li v='"+dataz+"' t='"+dataz+"'><span>"+dataz_new+"</span></li>";
//		console.log(dataz_new);
//		var datatime = data[i].time;
//		var start_time =dataz+" "+datatime.split("-")[0];
//		var end_time =dataz+" "+datatime.split("-")[1];
//		//获取时间段
//		var arr =gettimeList(Date.parse(new Date(start_time.replace(/\-/g,"/"))),Date.parse(new Date(end_time.replace(/\-/g,"/"))),Date.parse(new Date(data_w+" 0:0:0")));
//		//载入转换后的时间
//		for(var j=0;j<arr.length-1;j++){
//		   html+="<li class='click' v='"+arr[j]+"' id='1'><div>"+arr[j]+"</div></li>";
//		}
//		html3+="<ul class=''>"+html+"</ul>";
//		
//		//$(".consultation-pop .box .time").children("ul").eq(i).append(html);
//	 
//	     //初始化，如果不选择日期则默认第一天
//	      if(i==0){
//	     	$("#dateLabel").text(dataz);
//			$("#serviceDate").val(dataz);
////			$("#serviceTime").val(arr[0]);//如果不选时间，默认第一条
//	     }
//  }
	var html = "";
   	if(data==null) {
	   mui.toast("当前医生没有设置对应的服务 时间!");
	   return false;
	}
   	
   	var nowDate = moment().format('YYYY-MM-DD HH:mm')
    for(i in data){
    	var time=data[i].date+" ";
    	time += data[i].time.split("-")[1]
    	if(moment(nowDate).diff(moment(time))<=0){
			html+='<li v="'+data[i].date+'" t="'+data[i].time+'">'+data[i].date+'<span>'+data[i].time+'</span></li>';
		}
	}
    $(".consultation-pop .box .date ul").html(html);
//	var time = $($(".consultation-pop .box .date ul li")[0]).attr("v")+" ";
//	time+= $($(".consultation-pop .box .date ul li")[0]).attr("t").split("-")[1];
//	if(moment(nowDate).diff(moment(time))<=0){
//		$($(".consultation-pop .box .date ul li")[0]).show()
//	}else{
//		$($(".consultation-pop .box .date ul li")[0]).hide()
//	}
   // $(".consultation-pop .box .time").html(html3);
	
//	var ulWidth=$(".consultation-pop .box .date ul li").length*$(".consultation-pop .box .date ul li").width();
//	$(".consultation-pop .box .date ul").width(ulWidth);
    
//  var leng=$(".consultation-pop .box .time ul").eq(0).find("li").length;
//  if(leng==0){
//  	$("#dateLabel").text(dataz);
//  	$(".consultation-pop .box .date ul li").eq(0).hide();
//		$(".consultation-pop .box .time ul").eq(0).hide();
//	    $(".consultation-pop .box .date ul li").eq(1).addClass("active");
//		$(".consultation-pop .box .time ul").eq(1).addClass("active");
//  }else{
//	    $(".consultation-pop .box .date ul li").eq(0).addClass("active");
//		$(".consultation-pop .box .time ul").eq(0).addClass("active");
//  }
	//选中第一个
	$(".consultation-pop .box .date ul li").click(function(){
		var $index=$(this).index();  
		var dateValue=$(this).attr("v");
		var timeValue=$(this).attr("t");
		$("#dateLabel").text(dateValue);
		$("#serviceDate").val(dateValue);
		$("#serviceTime").val(timeValue);//如果不选时间，默认第一条
		$(this).addClass("active").siblings().removeClass("active");
		$(".consultation-pop .box .time ul li").removeClass("active");
		$(".consultation-pop .box .time ul").eq($index).addClass("active").siblings().removeClass("active");
		$(".consultation-pop .box .time ul li").removeClass("active");
		//$("#serviceTime").val("");
	});
//	$(".consultation-pop .box .time ul .click").click(function(){
//		$(this).addClass("active").siblings().removeClass("active");
//		var thisValue=$(this).attr("v"); 
//		$("#serviceTime").val(thisValue);
//		$(this).parent().siblings().find("li").removeClass("active");
//	});
}
</script>
